import { getAreaObj, uploadType } from '@/utils/util'

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '所属省',
			prop: 'provinceName',
			span: 12
		},
		{
			label: '所属市',
			prop: 'cityName',
			span: 12
		},
		{
			label: '所属区',
			prop: 'areaName',
			span: 12
		},
		{
			label: '机构名称',
			prop: 'organizationName',
			span: 12
		},
		{
			label: '预警类型',
			prop: 'alarmTypeLabel',
			span: 12
		},
		{
			label: '预警时间',
			prop: 'alarmTime',
			span: 12
		},
		
		{
			label: '预警原因',
			prop: 'alarmReasonLabel',
			span: 12
		},
		{
			label: '是否处理',
			prop: 'isDispose',
			dicData: [
				{
					label: '是',
					value: 1,
				},
				{
					label: '否',
					value: 2,
				},
			],
			span: 12
		},
		{
			label: '处理人',
			prop: 'disposeUserName',
			span: 12
		},
		{
			label: '处理内容',
			prop: 'disposeContent',
			span: 12
		},
		{
			label: '处理图片',
			prop: 'disposePic',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'picture-card',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			changeField: true,
			span: 12
		},
		{
			label: '处理时间',
			prop: 'disposeTime',
			span: 12,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '预警时间', prop: 'alarmTime' },
		{ label: '预警原因', prop: 'alarmReasonLabel' },
		{ label: '处理状态', prop: 'isDispose' },
		{ label: '处理人', prop: 'disposeUserName' },
		{ label: '处理时间', prop: 'disposeTime' },
		{
			label: '操作',
			prop: 'menu',
			width: 100,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_pbAlarm_page',
}
export const baseConfig = {
	pageName: '预警记录',
	dictcodes: [],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'sampleTime',
	exportMqTopic: '/ning/export/',
	api,
	auth: {
		...api,
	},
	paramsObj: {
		alarmType: 2,
		source: 1,
	},
	menuBtn: [
		{
			icon: 'detail',
			label: '查看',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		},
	],
	beforeOnLoadFormate: async (params) => {
		return new Promise((resolve, reject) => {
			const areaObj: any = getAreaObj(params.areas)
			resolve({
				...params,
				...areaObj,
				areas: undefined,
			})
		})
	},
	dialogConfig: {
		width: '55%',
	},
	formConfig,
	tableConfig,
	detailConfig: formConfig,
}
